package string;

import java.util.LinkedList;

public class MaximumNestingDepthOfTheParentheses1614 {
    public int maxDepth(String s) {
        int max = 0;
        int depth = 0;
        for (int i = 0; i < s.length(); i++) {
            char c = s.charAt(i);
            if (c == '(') {
                depth++;
            }
            if(c == ')'){
                max = Math.max(max,depth);
                depth--;
            }
        }
        return max;
    }

}
